import { Login } from "@/entities/Login.js";

/**
 * 
 * 用例层
 * 
 * 请求接口
 * 数据转换在此层完成
 * 返回业务实体
 */

export function loginUseCase(gateway) {
  return async (params) => {
    const httpRes = await gateway.login(params);
    const { accessToken, refreshToken, user,  permissions, } = httpRes;
    return new Login(accessToken, refreshToken, user, permissions);
  };
}
// 微信登录
export function wxchatLoginUseCase(gateway) {
  return async (params) => {
    const httpRes = await gateway.wxchatLogin(params);
    return httpRes;
  };
}

// 获取企业签名
export function getConfigSignatureUseCase(gateway) {
  return async (params) => {
    const httpRes = await gateway.getConfigSignature(params);
    console.log('获取到的access_token:', httpRes);
    return httpRes;
  };
}
// 获取应用签名
export function getAgentConfigSignatureUseCase(gateway) {
  return async (params) => {
    const httpRes = await gateway.getAgentConfigSignature(params);
    return httpRes;
  };
}